package com.resou.reader.bookdetail.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.resou.reader.R;

/**
 * Created by ${Garrett} on 2018/9/6.
 * Contact me krouky@outlook.com
 */
public class ReportCommentPopDialog extends PopupWindow implements View.OnClickListener {

    public static final int TYPE_ABUSE = 0;//辱骂
    public static final int TYPE_ADVERTISING = 1;//广告
    public static final int TYPE_PORNOGRAPHIC = 2;//色情
    public static final int TYPE_POLITICS = 3;//政治敏感


    private ReportCallback callback;

    public ReportCommentPopDialog(Context context, ReportCallback callback) {
        this.callback = callback;
        setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setOutsideTouchable(true);
        setFocusable(true);
//        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        View contentView = LayoutInflater.from(context).inflate(R.layout.report_comment_layout, null, false);
        setContentView(contentView);

        contentView.findViewById(R.id.report_abuse).setOnClickListener(this);
        contentView.findViewById(R.id.report_advertising).setOnClickListener(this);
        contentView.findViewById(R.id.report_pornographic).setOnClickListener(this);
        contentView.findViewById(R.id.report_politics).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.report_abuse:
                callback.report(TYPE_ABUSE);
                break;
            case R.id.report_advertising:
                callback.report(TYPE_ADVERTISING);
                break;
            case R.id.report_pornographic:
                callback.report(TYPE_PORNOGRAPHIC);
                break;
            case R.id.report_politics:
                callback.report(TYPE_POLITICS);
                break;
        }
        dismiss();
    }

    public interface ReportCallback {
        void report(int type);
    }
}
